import React, { Component } from 'react';
import './MaybeLike.css'


class MaybeLike extends Component{
    constructor(){
        super();
        this.state = {
            goods : [],
            isLoad:false
        }
    }
    render(){
        // console.log(this.state.goods);
        if(this.state.isLoad){
            var lis = this.state.goods.map((obj,ind)=>(
                <li key={ind}>
                    <img src={"http://localhost:3001/img/"+obj.goodsimg} alt=""/>
                    <b>{obj.goodsname}</b><br/>
                    <span>￥{obj.goodsprice}.00</span>
                </li>
            ))
           setTimeout(()=>{
               this.props.myscroll.refresh();
           },1000)
        }

        return(
           <div className="MaybeLike">
               {this.state.isLoad&&<ul>{lis}</ul>}
           </div>
        )
    }
    componentDidMount(){
        this.$axios.get("http://localhost:3001/goods").then(res=>{
            this.setState(state=>{
                state.goods = res.data;
                state.isLoad=true;
                return state;
            })
        })

    }
}


export default MaybeLike;